package cn.wolfcode.wolf2w.common.core.query;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Getter
@Setter
@ApiModel(value = "查询参数", description = "分页查询的父类维护了当前页、大小，关键字等信息")
public class QueryObject implements Serializable {
    @ApiModelProperty(value = "当前页", name = "currentPage",required = true, dataType = "Integer", example = "1")
    private int currentPage = -1;
    @ApiModelProperty(value = "当前页", name = "pageNum", dataType = "Integer")
    private int pageNum = -1;
    @ApiModelProperty(value = "页面大小", name = "pageSize",required = true, dataType = "Integer", example = "10")
    private int pageSize = 10;
    @ApiModelProperty(value = "关键字", name = "keyword")
    private String keyword;

    public int getCurrentPage(){
        if(currentPage != -1){
            return this.currentPage;
        }
        if(currentPage == -1 && pageNum != -1){
            return pageNum;
        }
        return 1;
    }

    public int getPageNum(){
        if(pageNum != -1){
            return this.pageNum;
        }
        if(pageNum == -1 && currentPage != -1){
            return currentPage;
        }
        return 1;
    }
}
